"""
检查相关的操作
"""

import pytest_check as c


def check_equal(real, expect, key_str):
    """
    比较两个字典中key对应的value是否相同
    :param real: 实际的结果
    :param expect: 预期的结果
    :param key_str: key的字符串，用逗号分隔
    :return:
    """
    keys = key_str.split(",")
    for key in keys:
        r = real.get(key)  # 根据key取出字典中的value real[key]
        e = expect.get(key)
        r = str(r)  # 强转成字符串
        e = str(e)
        try:
            c.equal(r, e)  # pytest_check 中提供的方法，底层也是assert
        except Exception as e:
            print(f"校验{key}失败，预期结果为：{e}，实际结果为：{r}")
